<template>
  <div>
    <div id="main" style="width: 100%;height: 600px">

    </div>
  </div>
</template>

<script>
import {getPieData} from "@/api/ech";

export default {
  data() {
    return {
      pieData:[]
    };
  },
  comments: {},
  created() {
  },
  mounted() {
    this.getData()
  },
  methods: {
    showPie() {
      var data = this.pieData
      var chartDom = document.getElementById('main');
      var myChart = this.$echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: '诊治类别统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: data,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };

      option && myChart.setOption(option);
    },
    async getData(){
      await getPieData().then(res=>{

        this.pieData=res.data

      }).catch(error=>{})

      this.showPie()
    }

  }
}
</script>



<style scoped>

</style>
